/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package gpsData;
import javax.microedition.location.Coordinates;
import javax.microedition.location.Criteria;
import javax.microedition.location.Location;
import javax.microedition.location.LocationException;
import javax.microedition.location.LocationProvider;

/**
 *
 * @author mgeden
 */
public class GPSLocation {
    private double latitude,longitude,altitude;

    public  GPSLocation ()  {
        try {
            // Set criteria for selecting a location provider:
            // accurate to 500 meters horizontally
            Criteria cr = new Criteria();
            cr.setHorizontalAccuracy(500);

            // Get an instance of the provider
            LocationProvider lp = LocationProvider.getInstance(cr);

            // Request the location, setting a one-minute timeout
            Location l = lp.getLocation(60);
            Coordinates c = l.getQualifiedCoordinates();
            if (c != null) {
                // Use coordinate information
                latitude = c.getLatitude();
                longitude = c.getLongitude();
                altitude = c.getAltitude();
                
            }
        } catch (LocationException ex) {
            ex.printStackTrace();
        } catch (InterruptedException ex) {
            ex.printStackTrace();
        }
           
            
     
}
        public double getLatitude ()
        {
            return latitude;
        }
         public double getLongitude ()
        {
            return longitude;
        }
          public double getAltitude()
        {
            return altitude;
        }
         
}

